package org.openmore.opc.service;

import org.openmore.common.exception.OpenmoreException;
import org.openmore.opc.dto.LoginParams;
import org.openmore.opc.dto.UserProfileDto;
import org.openmore.opc.entity.enums.LoginType;
import org.openmore.opc.shiro.OpenmoreToken;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public interface AccountService {

    /**
     * 获得当前登录的员工用户
     * @return
//    Staff getLoginStaff();

    /**
     * 执行shiro登录
     * @param token
     */
    void shiroLogin(OpenmoreToken token);

    /**
     * 执行登录操作，返后登录后的用户信息封装
     * @param request
     * @param tenantId :应用ID
     * @param params
     * @return
     */
    UserProfileDto login(HttpServletRequest request, String tenantId, LoginParams params);

    /**
     * 退出登录
     */
    void logout();

    String sendCaptcha(String tenantId, String mobile) throws OpenmoreException;

    boolean verifyCaptcha(String tenantId, String mobile, String captcha) throws OpenmoreException;

    /**
     * 绑定手机，查找是否有居民信息和员工信息相关联，更新微信用户信息
     * @param openid
     * @param mobile
     * @param captcha
     * @return
     * @throws OpenmoreException
     */
    UserProfileDto phoneBind(String tenantId, LoginType type, String openid, String mobile, String captcha);


    /**
     * 向登录邮箱用户的手机号发送短信验证码
     */
    String sendCaptchaByLoginEmail(String tenantId, String email) throws OpenmoreException;


    /**
     * 使用登录邮箱和手机验证证码安全登录
     * @param email
     * @param captcha
     * @return
     * @throws OpenmoreException
     */
    boolean securityLoginWith(String tenantId, String email, String captcha) throws OpenmoreException;

    /**
     * 获得图片验证码图片流
     * @throws OpenmoreException
     */
    void getImgCaptcha(HttpServletRequest request, HttpServletResponse response, int width, int height) throws OpenmoreException;

    /**
     * 校验图片验证码
     * @param request
     * @throws OpenmoreException
     */
    void verifyImgCaptcha(HttpServletRequest request, String captcha) throws OpenmoreException;


    UserProfileDto getUserProfile(LoginType type, String openId);

    /**
     * 获得当前登录用户信息
     * @return
     */
    UserProfileDto getLoginInfo();
}